package sanshui.system.trade.factory.data.cleaning;

import cn.hutool.core.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import sanshui.system.trade.config.SpringContextHolder;
import sanshui.system.trade.db.entity.StockTblDailyRt;
import sanshui.system.trade.db.entity.StockTblFavoriteBasic;
import sanshui.system.trade.db.entity.TradeTargetCode;
import sanshui.system.trade.db.mapper.TradeDataTblMapper;
import sanshui.system.trade.pojo.StockInfoVo;
import sanshui.system.trade.service.IStockInfoService;
import sanshui.system.trade.util.CommonTimeUtil;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 清理A股日线级别数据
 * */
@Slf4j
@Service
public class CleAGuDailyData {

    //A股日线级别，每日固定取最晚145000到数据
    private static final String FIXED_TIME = "145000";
    // 取瞬时时间到误差: n * 60s
    private static final Integer DELTA_SECONDS = 15 * 60;

    @Resource
    IStockInfoService stockInfoService;
    @Resource
    TradeDataTblMapper tradeDataTblMapper;
    private List<String> getTargetCode(List<TradeTargetCode> favoriteCodes){
        List<String> codes = new ArrayList<>();
        for (TradeTargetCode favoriteCode : favoriteCodes) {
            codes.add(favoriteCode.getTsCode());
        }
        return codes;
    }

    private List<StockTblDailyRt> parseRtData(List<StockInfoVo> list){
        List<StockTblDailyRt> stockTblDailyRts = BeanUtil.copyToList(list, StockTblDailyRt.class);
        for (StockTblDailyRt stockTblDailyRt : stockTblDailyRts) {
            stockTblDailyRt.setTradeTime(FIXED_TIME);
        }
        return stockTblDailyRts;
    }
}
